package hr.fer.zemris.schedulingRules;

import java.util.Collections;
import java.util.Comparator;

import hr.fer.zemris.ShopFloor.Job;
import hr.fer.zemris.ShopFloor.Shop;

public class SRPTRule implements Comparator<Job> {
	
	@Override
	public int compare(Job j1, Job j2) {
		return j1.getP().compareTo(j2.getP());
	}
		
	public Job schedule(Shop s) {
		Collections.sort(s.getAllJobs(), new SRPTRule());
		Job jobToBeScheduled = s.getJob(0);
		s.getAllJobs().remove(s.getJob(0));
		return jobToBeScheduled;
	}
	
	public static void main(String[] args) {
		Shop s = new Shop(5);
		Collections.sort(s.getAllJobs(), new SRPTRule());
		for(int i = 0; i < 5; i++)
			System.out.println(s.getJob(i).getP());
		
		SRPTRule srpt = new SRPTRule();
		
		Job j = srpt.schedule(s);
		System.out.println(j.getP());
	}
}
